<?php

//搜索功能
if(!empty($_POST))
{
	if(empty($_POST['search']))
	{
		echo "<script>
				window.history.back();
			  </script>";
	  	die;
	}
	$contents = $_POST['search']; 
	$re_news = selectone('news',"title like '%$contents%'");
	$re_pro = selectone('product',"name like '%$contents%'");
	$news = json_encode($re_news['title']);
	$product = json_encode($re_pro['name']);
//	print_r($news);
//	print_r($product);
//	die;
	if(!empty($_POST['search'])&&!empty($re_news))
	{
		echo "<script>
				window.location = 'index.php?a=index&b=news&c=news&search='+$news;
			  </script>";
	  	die;
	}else if(!empty($_POST['search'])&&!empty($re_pro))
	{
		echo "<script>
				window.location = 'index.php?a=index&b=product&c=product&search='+$product;
			  </script>";
	  	die;
	}else
	{
		echo "<script>
				alert('未查询到该内容');
				window.history.back();
			  </script>";
	  	die;
	}
}

include('app/index/public/html/_header.html');
?>